package com.zoe.onelink.test.integration.logging.trace;

/**
 * <p>标题: </p>
 * <p>描述: </p>
 * <p>版权: Copyright (c) 2022</p>
 * <p>公司: 智业软件股份有限公司</p>
 *
 * @version: 1.0
 * @author: ruansheng
 * @date: 2022-10-25
 */

import brave.handler.MutableSpan;
import brave.handler.SpanHandler;
import brave.propagation.TraceContext;
import com.zoe.onelink.logging.trace.autoconfigure.OnelinkTraceZipkinConfiguration;
import lombok.Getter;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component(OnelinkTraceZipkinConfiguration.ZIPKIN_SPAN_STATISTICS_HANDLER)
public class IntegrationSpanFinishHandler extends SpanHandler {

    @Getter
    private final List<MutableSpan> spans = new ArrayList<>();

    @Override
    public boolean end(TraceContext context, MutableSpan span, Cause cause) {
        this.spans.add(span);
        return super.end(context, span, cause);
    }

}
